<?php
/*
 * Copyright notice
 * 
 * (c) 2009 MH-Dev.de, Martin Hesse <info@mh-dev.de>
 * 
 * This script is part of the MH-Dev.-Board project. The MH-Dev.-Board 
 * is free software; you can redistribute it and/or modify it under the 
 * terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, 
 * or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty 
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU 
 * General Public License along with this program; if not, 
 * see http://www.gnu.org/licenses/.
 */


/**
 * Updates for the board
 *
 * @author	Martin Hesse <info@mh-dev.de>
 * @package	MH-Dev.-Board
 */
class UpdateController extends Zend_Controller_Action
{
	private $registry; // registry
	private $auth; // user-values
	private $settings; // board-settings
	
	public function init()
	{		
		// registry
		$this->registry = Zend_Registry::getInstance();
		
		// settings
		$this->settings	= $this->registry->get('settings');
		
		// auth
		$auth = Zend_Auth::getInstance();
		$this->view->auth = $auth->hasIdentity();
    	
		if($auth->hasIdentity())
		{
			$this->view->auth_role 			= $auth->getIdentity()->role;
			$this->view->username 			= $auth->getIdentity()->username;
			$this->view->auth_uid			= $auth->getIdentity()->uid;
			$this->view->unread_messages	= $auth->getIdentity()->count_unread_messages;
		}
		else
		{
			$this->view->username 	= $this->registry->get('lang')->_('guest');
		}

		$this->auth = $auth;
    	
		// lang
		$this->view->translate = $this->registry->get('lang');
		
		// flash messenger
		$this->view->flashMessenger	= $this->_helper->FlashMessenger;
	}
	
	/*
	 * Version-Check
	 * 
	 * @param null
	 * 
	 * @return void
	 */
	public function indexAction()
	{
		
	}
	
	private function getLatestVersion()
	{
		$source			= 'http://example.com/wanted.html';
		$destination	= $_SERVER['DOCUMENT_ROOT'].'/'.basename($source);
		
		file_put_contents($destination,file_get_contents($source));
	}
	
	private function extractArchive()
	{
		$zip		= new ZipArchive();
		$zipArchive	= 'latest.zip';
		
		if($zip->open($zipArchive))
		{
			$zip->extractTo('../');
			$zip->close();
		}
	}
}
?>